package com.uvt.agenda.commands;

import com.uvt.agenda.EventsProvider;
import com.uvt.agenda.pdf.PdfCalendar;
import com.uvt.agenda.pdf.PdfBuilder;
import com.uvt.agenda.pdf.Builder;
import android.content.Context;


import java.util.Locale;

/**
 * Created by oana on 02/02/14.
 * 11:36
 */
public class GeneratePDFDocument implements Command {
    private int year;
    private int month;
    private int day;
    private Context context;

    public GeneratePDFDocument(Context context,int year) {
        this.context = context;
        this.year = year;
    }

    public GeneratePDFDocument(Context context,int year, int month) {
        this.context = context;
        this.year = year;
        this.month = month;
    }

    public GeneratePDFDocument(Context context,int year, int month, int day) {
        this.context = context;
        this.year = year;
        this.month = month;
        this.day = day;
    }

    @Override
    public void execute() {
        try {
            Builder pdfBuilder = new PdfBuilder();
            try {
                pdfBuilder.Build(this.context, EventsProvider.getInstance());
            } catch (Exception e) {
                e.printStackTrace();
            }
            if(this.month>0 && this.day>0){
                pdfBuilder.createPDF(new Locale("en"), year,month,day);
            }
            else if(this.month>0){
                pdfBuilder.createPDF(new Locale("en"), year,month);
            }
            else{
                pdfBuilder.createPDF(new Locale("en"), year);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
